package com.sergio.gestion.entities;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository(value = "socioDao")
public class SocioDaoImpl implements SocioDao {

	private EntityManager em = null;

	/*
	 * Sets the entity manager.
	 */
	@PersistenceContext
	public void setEntityManager(EntityManager em) {
		this.em = em;
	}

	@Transactional(readOnly = true)
	@SuppressWarnings("unchecked")
	public List<Socio> getAll() {
		return em.createQuery("select p from Socio p order by p.id")
				.getResultList();
	}

	@Transactional(readOnly = false)
	public void saveProduct(Socio socio) {
		em.merge(socio);
	}

}
